package cn.iocoder.yudao.module.scrm.controller.admin.approve;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.scrm.controller.admin.approve.vo.ApproveReqVO;
import cn.iocoder.yudao.module.scrm.controller.admin.approve.vo.ApproveRespVO;
import cn.iocoder.yudao.module.scrm.controller.admin.invoice.vo.InvoiceSaveReqVO;
import cn.iocoder.yudao.module.scrm.service.approve.ApproveService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

/**
 * @author pg
 * @project zysx
 * @description 审批
 * @date 2024/8/6 18:05:02
 */
@Tag(name = "管理后台 - 审批")
@RestController
@RequestMapping("/scrm/approve")
@Validated
public class ApproveController {

    @Resource
    private ApproveService approveService;

    @PutMapping("/update")
    @Operation(summary = "更新审批状态")
    @PreAuthorize("@ss.hasPermission('scrm:approve:submit')")
    public CommonResult<ApproveRespVO> updateInvoice(@Valid @RequestBody ApproveReqVO approveReqVO) {
        ApproveRespVO resp = approveService.approve(approveReqVO);
        return success(resp);
    }
}
